import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WorkVO, WorkForm, WorkQuery } from '@/api/system/work/types';

/**
 * 查询动土作业列表
 * @param query
 * @returns {*}
 */

export const listWork = (query?: WorkQuery): AxiosPromise<WorkVO[]> => {
  return request({
    url: '/system/work/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询动土作业详细
 * @param id
 */
export const getWork = (id: string | number): AxiosPromise<WorkVO> => {
  return request({
    url: '/system/work/' + id,
    method: 'get'
  });
};

/**
 * 新增动土作业
 * @param data
 */
export const addWork = (data: WorkForm) => {
  return request({
    url: '/system/work',
    method: 'post',
    data: data
  });
};

/**
 * 修改动土作业
 * @param data
 */
export const updateWork = (data: WorkForm) => {
  return request({
    url: '/system/work',
    method: 'put',
    data: data
  });
};

/**
 * 删除动土作业
 * @param id
 */
export const delWork = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/work/' + id,
    method: 'delete'
  });
};
